<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>升序降序</title>
	</head>
	<body>
		<p id="arrold"></p>
		<p>
			<input type="button" value="升序" onclick="asc()"/>
			<input type="button" value="降序" onclick="desc()"/>	
		</p>
		<p id="arrnew"></p>
		<script>
			var arr=[5,3,40,1,67];
			var old=document.getElementById('arrold');
			old.innerText=arr;
				var mynew=document.getElementById('arrnew');
			function asc(){
				mynew.innerText=arr.sout(function(a,b){return a-b});
			}
			
			function desc(){
				mynew.innerText=arr.sout(function(a,b){return b-a});
			}
		</script>
		
	</body>
</html>
